<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var \Magento\Braintree\Block\PayPal\Shortcut $block */

$containerId = $block->getContainerId();
$formId = $block->getSubmitFormId();
$paymentId = $block->getPaymentMethodNonceId();
$detailsId = $block->getPaymentDetailsId();
$isMiniCart = (bool)(int)$block->isInMiniCart();

$widgetName = 'braintreePayPalMinicart';

$config = [
    $widgetName => [
        'url' => $block->getButtonDataUrl(),
        'isMiniCart' => $isMiniCart,
        'formAction' => $block->escapeUrl($block->getReviewPageUrl()),
        'clientToken' => $block->escapeHtml($block->getClientToken()),
        'containerId' => ('#' . $containerId),
        'formId' => ('#' . $formId),
        'paymentId' => ('#' . $paymentId),
        'detailsId' => ('#' . $detailsId),
        'options' => [
            'amount' => $block->getAmount(),
            'currency' => $block->getCurrency(),
            'container' => $containerId,
            'singleUse' => true,
            'enableShippingAddress' => true,
            'enableBillingAddress' => $block->enableBillingAddress(),
            'locale' => $block->getLocale(),
            'merchantName' => $block->escapeHtml($block->getMerchantName()),
        ],
    ]
];

?>
<div data-label="<?php echo $block->escapeHtml(__('or')); ?>"
     class="paypal checkout <?php echo $block->escapeHtml($block->getShowOrPosition()) ?> paypal-logo"
    >
    <fieldset class="fieldset paypal items">
        <div id="<?php echo $block->escapeHtml($containerId); ?>"
             data-mage-init='<?php /* @noEscape */ echo json_encode($config); ?>'></div>
    </fieldset>
</div>
